package cn.quevo.cube.provide.data.validate;


import cn.quevo.cube.provide.data.entity.dto.ColumnValidateDto;
import cn.quevo.cube.provide.data.enums.DataValidate;

/**
 * 数据验证工厂类
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/14 6:00 PM
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
public class ColumnDataValidateFactory {

    /**
     * 数据验证
     *
     * @param columnValidateDto
     * @author July july_sky@foxmail.com
     * @date 2018/12/14 6:00 PM
     * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
     */
    public static void validate(ColumnValidateDto columnValidateDto) {
        DataValidate dataValidate = null;
        try {
            dataValidate = DataValidate.valueOf(columnValidateDto.getTypeCode().toUpperCase());
        } catch (Exception e) {
            dataValidate = DataValidate.valueOf(columnValidateDto.getColumnTypeCd().toUpperCase());
        }
        dataValidate.getValidateClass().validate(columnValidateDto);
    }
}
